package com.course.business.controller;

import com.course.result.ResponseDto;
import com.course.server.exception.ValidatorException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@ControllerAdvice
public class ControllerExceptionHandler {

    @ExceptionHandler
    @ResponseBody
    public ResponseDto validatorExceptionHandler(ValidatorException e) {
        ResponseDto<Object> responseDto = new ResponseDto<>();
        responseDto.setSuccess(false);
        log.error(e.getMessage());
        responseDto.setMessage("请求参数异常！");
        return responseDto;
    }


}
